Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Implement tracing & thiserror error types #29

Merged
merged 3 commits into from
Sep 1, 2023
Merged

Conversation

matheus23
Copy link
Member

This implements tracing messages using the tracing crate and error types using the thiserror crate.

Closes #25
Closes #26

I'm somewhat waiting for n0-computer/iroh-car#12 to land so I can improve the error types a bit.
Additionally, it'd be nice to have a better BlockStore trait eventually, so (1) we can get rid off the BlockStoreIncompatible error and (2) use a custom error type from the BlockStore instead of a hard-coded anyhow::Error.

@matheus23
Copy link
Member Author

@zeeshanlakhani Tagged you as a reviewer on this PR, specifically for the tracing commit ( 436c1b6 ), since you're more knowledgeable on tracing. LMK what you think ✌️

@matheus23
Copy link
Member Author

Clippy warning is triggered within the instrument macro, unfortunately: tokio-rs/tracing#2503

A little annoying.

I'll try ignoring the warning until that issue is closed.

Copy link
Member

@appcypher appcypher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉!

@matheus23 matheus23 merged commit 6cea1d2 into main Sep 1, 2023
9 checks passed
@matheus23 matheus23 deleted the matheus23/tracing branch September 1, 2023 09:53
}

match dag_verification.block_state(cid) {
BlockState::Have => continue,
BlockState::Unexpected => {
eprintln!("Warn: Received block {cid} out of order, may be due to bloom false positive.");
trace!(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trace! is the lowest level. Should this be a warn?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's trace intentionally.
I used to think of this as a warning - it's one of the things that if something goes wrong, this may happen more often.
But it's also something that just happens during normal execution, so more like some info.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah ok. yeah, from the comment it made it sound worse than it is :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switch from anyhow to thiserror, add error types Implement proper tracing using the tracing crate
3 participants